package DPT_01_06;


public class Solution {
	public String compressString(String S) {
		char[] strings = S.toCharArray();
		String res="";
		int len = strings.length;
		int start = 0;
		while (start < len) {
			int end = start;
			while (end < len && strings[start] == strings[end]) {
				end++;
			}
			res += strings[start];
			res += Integer.toString(end - start);
			start=end;
		}
		char[] r = res.toCharArray();
		if (len > r.length) {
			return res;
		}else {
			return S;
		}
	}
}
